<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>健康食谱</title>
      <link rel="stylesheet" type="text/css" href="../xhAdmin/css/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../xhAdmin/css/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../xhAdmin/css/themes/color.css">
    <link rel="stylesheet" type="text/css" href="../xhAdmin/css/demo/demo.css">
    <script type="text/javascript" src="../xhAdmin/js/jquery.min.js"></script>
    <script type="text/javascript" src="../xhAdmin/js/jquery.easyui.min.js"></script>
</head>

<body>
    <div id="toolbar-jobLink">
        <a href="javascript:void(0)" id="jobLinkAddBtn" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="jobLinkAdd()">添加</a>
        <a href="javascript:void(0)" id="jobLinkEditBtn" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="jobLinkEdit()">修改</a>
        <a href="javascript:void(0)" id="jobLinkDestroyBtn" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="jobLinkDestroy()">删除</a>
    </div>
    <table id="jobLink-table" class="easyui-datagrid" data-options="fit:true,border:false,url:'../xhJobLink/all',method:'get'" style="width:auto;height:100%" toolbar="#toolbar-jobLink" pagination="true" rownumbers="true" fitColumns="true" singleSelect="true" pageSize="20">
        <thead>
            <tr>
              	<th field="style" width="16%" align="center">爬取类别分类</th>
              	<th field="name" width="16%" align="center">网站名称</th>
                <th field="link" width="17%" align="center">网站网址</th>
                <th field="description" width="17%" align="center">网站简介</th>
                <th field="freq" width="17%" align="center">抓取频率</th>
                <th field="oldTime" width="17%" align="center">记录创建时间</th>
                <th field="newTime" width="17%" align="center">最新更改时间</th>
                <th field="timestamp" width="17%" align="center">时间戳</th>
            </tr>
        </thead>
    </table>
    <div id="dlg-jobLinkAdd" class="easyui-dialog" style="width:650px;height:393px;padding:1px 1px" closed="true" buttons="#dlg-jobLinkAdd-btn" align="center" data-options="modal:true">
        <form id="fm-jobLinkAdd" method="post" novalidate>
            <table class="pattern" border="0">
              <tr>
				<th width="18%">爬取类别分类：</th>
				<td width="32%"><input type="text" id="style" name="style" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">网站名称：</th>
				<td width="32%"><input type="text" id="name" name="name" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
				<th width="18%">网站网址：</th>
				<td width="32%"><input type="text" id="link" name="link" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">抓取频率：</th>
				<td width="32%"><input type="text" id="freq" name="freq" class="easyui-textbox" style="width:100%"></td>
			</tr>
			
			<tr>
                    <th>网站简介：</th>
                    <td colspan="3">
                        <input class="easyui-textbox" id="description" name="description" style="width:100%;height:80px" data-options="multiline:true" style="width:100%" />
                    </td>
                </tr>
			 
            </table>
        </form>
    </div>
    <div id="dlg-jobLinkAdd-btn">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="jobLinkAddSave()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg-jobLinkAdd').dialog('close')" style="width:90px">关闭</a>
    </div>
    <div id="dlg-jobLinkEdit" class="easyui-dialog" style="width:650px;height:393px;padding:1px 1px" closed="true" buttons="#dlg-jobLinkEdit-btn" align="center" data-options="modal:true">
        <form id="fm-jobLinkEdit" method="post" novalidate>
            <table class="pattern" border="0">
			  <tr>
				<th width="18%">爬取类别分类：</th>
				<td width="32%"><input type="text" id="style" name="style" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">网站名称：</th>
				<td width="32%"><input type="text" id="name" name="name" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
				<th width="18%">网站网址：</th>
				<td width="32%"><input type="text" id="link" name="link" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">抓取频率：</th>
				<td width="32%"><input type="text" id="freq" name="freq" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
                    <th>网站简介：</th>
                    <td colspan="3">
                        <input class="easyui-textbox" id="description" name="description" style="width:100%;height:80px" data-options="multiline:true" style="width:100%" />
                    </td>
                </tr>
			 
            <input type="hidden" name="id" />
            <input type="hidden" name="timestamp" />
			</table>
        </form>
    </div>
    <div id="dlg-jobLinkEdit-btn">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="jobLinkEditSave()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg-jobLinkEdit').dialog('close')" style="width:90px">关闭</a>
    </div>
    <div id="dlg-jobLinkReadonly" class="easyui-dialog" style="width:650px;height:393px;padding:1px 1px" closed="true" buttons="#dlg-jobLinkReadonly-btn" align="center" data-options="modal:true">
        <form id="fm-jobLinkReadonly" method="post" novalidate>
            <table class="pattern" border="0">
			   <tr>
				<th width="18%">爬取类别分类：</th>
				<td width="32%"><input type="text" id="style" name="style" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">网站名称：</th>
				<td width="32%"><input type="text" id="name" name="name" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
				<th width="18%">网站网址：</th>
				<td width="32%"><input type="text" id="link" name="link" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">抓取频率：</th>
				<td width="32%"><input type="text" id="freq" name="freq" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
				<th width="18%">记录创建时间：</th>
				<td width="32%"><input type="text" id="oldTime" name="oldTime" class="easyui-textbox" style="width:100%"></td>
				<th width="18%">最新更改时间：</th>
				<td width="32%"><input type="text" id="newTime" name="newTime" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
				<th width="18%">时间戳：</th>
				<td width="72%"><input type="text" id="timestamp" name="timestamp" class="easyui-textbox" style="width:100%"></td>
			</tr>
			<tr>
                    <th>网站简介：</th>
                    <td colspan="3">
                        <input class="easyui-textbox" id="description" name="description" style="width:100%;height:80px" data-options="multiline:true" style="width:100%" />
                    </td>
                </tr>
			 
            <input type="hidden" name="id" />
            <input type="hidden" name="timestamp" />
			</table>
        </form>
    </div>
    <div id="dlg-jobLinkReadonly-btn">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg-jobLinkReadonly').dialog('close')" style="width:90px">关闭</a>
    </div>
    <script type="text/javascript">
    $(document).ready(function() {
        /*$.post('/jg/checkScope', {
            sessionName: 'f9'
        }, function(data) {
            if (data == false) {
                $('#toolbar-jobLink #jobLinkAddBtn').hide();
                $('#toolbar-jobLink #jobLinkEditBtn').hide();
                $('#toolbar-jobLink #jobLinkDestroyBtn').hide();
            }
        }, 'json');*/

        $("#jobLink-table").datagrid({
            //双击事件  
            onDblClickRow: function(index, row) {
                if (row) {
                    $('#dlg-jobLinkReadonly').dialog('open').dialog('center').dialog('setTitle', '查看爬虫信息');
                    $('#fm-jobLinkReadonly').form('load', row);
                }
            }
        });

    });

    function jobLinkAdd() {
        $('#dlg-jobLinkAdd').dialog('open').dialog('center').dialog('setTitle', '添加爬虫抓取信息');
        $('#fm-jobLinkAdd').form('clear');
    }

    function jobLinkAddSave() {
        $('#fm-jobLinkAdd').form('submit', {
            url: '../xhJobLink/add',
            onSubmit: function() {
                //进行表单验证
                //如果返回false阻止提交
                return $(this).form('enableValidation').form('validate');
            },
            success: function(data) {
                var data = eval('(' + data + ')'); // change the JSON string to javascript object
                if (data.result == 'success') {
                    $('#dlg-jobLinkAdd').dialog('close');
                    $('#jobLink-table').datagrid('reload');
                    $.messager.show({ // show error message
                        title: '操作完成',
                        msg: data.description
                    });
                } else {
                    $.messager.show({ // show error message
                        title: '出错了',
                        msg: data.description
                    });
                }
            }
        });

    }

    function jobLinkEdit() {
        var row = $('#jobLink-table').datagrid('getSelected');
        if (row) {
            $('#dlg-jobLinkEdit').dialog('open').dialog('center').dialog('setTitle', '修改爬虫抓取信息');
            $('#fm-jobLinkEdit').form('load', row);
        }
    }

    function jobLinkEditSave() {
        $('#fm-jobLinkEdit').form('submit', {
            url: '../xhJobLink/update',
            onSubmit: function() {
                //进行表单验证
                //如果返回false阻止提交
                return $(this).form('enableValidation').form('validate');
            },
            success: function(data) {
                var data = eval('(' + data + ')'); // change the JSON string to javascript object
                if (data.result == 'success') {
                    $('#dlg-jobLinkEdit').dialog('close');
                    $('#jobLink-table').datagrid('reload');
                    $.messager.show({ // show error message
                        title: '操作完成',
                        msg: data.description
                    });
                } else {
                    $.messager.show({ // show error message
                        title: '出错了',
                        msg: data.description
                    });
                }
            }
        });
    }

    function jobLinkDestroy() {
        var row = $('#jobLink-table').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除', '是否彻底删除该爬虫抓取信息？？？', function(r) {
                if (r) {
                    $.post('../xhJobLink/delete', {
                        id: row.id
                    }, function(data) {
                        if (data.result == 'success') {
                            $('#jobLink-table').datagrid('reload'); // reload the user data
                            $.messager.show({ // show error message
                                title: '操作完成',
                                msg: data.description
                            });
                        } else {
                            $.messager.show({ // show error message
                                title: '出错了',
                                msg: data.description
                            });
                        }
                    }, 'json');
                }
            });
        }
    }
    </script>
</body>

</html>
